package com.youlu.campus.web.data.controller;


import com.youlu.campus.entity.VO.req.ActivityChannelStatisticsPVUVReq;
import com.youlu.campus.service.activity.ActivityChannelStatisticsService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class ActivityChannelStatisticsController {

    @Autowired
    private ActivityChannelStatisticsService activityChannelStatisticsService;

    @PostMapping(value = "/public/channel/statistics")
    public QResult pvUv(@RequestBody @Validated ActivityChannelStatisticsPVUVReq req, HttpServletRequest request, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return QResult.fail(bindingResult.getFieldError().getDefaultMessage());
        }
        //uvPv.setClientIp(CommonUtils.getRemoteIp(request));
       // uvPv.setAppClientIp(request.getLocalAddr());
        activityChannelStatisticsService.addPVUV(req);
        return QResult.success(null);
    }
}
